Preparativos

Carga de paquetes

library(readr)
library(dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
library(plotly)

Lectura de datos

bioestadisticas <-
  read_delim("bioestadisticas.csv")

Transformaciones

bioestadisticas <-
  bioestadisticas %>%
  mutate(fecha = as.Date(fecha, format = "%Y-%m-%d")) %>%
  arrange(fecha)

Análisis

Peso

Peso vs. grasa corporal

peso_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = peso, y = grasa_corporal)) +
  geom_point(color = "red") +
  geom_smooth(color = "black") +
  labs(title = "Peso vs. grasa corporal") +
  theme_minimal()

ggplotly(peso_grasa)

Peso vs. músculo esquelético

peso_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = peso, y = musculo_esqueletico)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Peso vs. músculo esquelético") +  
  theme_minimal()

ggplotly(peso_musculo)

Músculo esquelético vs. grasa corporal

musculo_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = musculo_esqueletico, y = grasa_corporal)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Músculo esquelético vs. grasa corporal") +  
  theme_minimal()

ggplotly(musculo_grasa)

Peso por mes

peso_x_mes <-
  bioestadisticas %>%
  mutate(mes = format_ISO8601(fecha, precision = "ym")) %>%
  group_by(mes) %>%
  summarise(peso = mean(peso, na.rm = TRUE))

grafico_peso_x_mes <-
  peso_x_mes %>%
  ggplot(aes(x = mes, y = peso)) +
  geom_col() +
  labs(title = "Peso promedio por mes") +  
  theme_minimal()

ggplotly(grafico_peso_x_mes)

Grasa corporal por mes

grasa_x_mes <-
  bioestadisticas %>%
  mutate(mes = format_ISO8601(fecha, precision = "ym")) %>%
  group_by(mes) %>%
  summarise(grasa_corporal = mean(grasa_corporal, na.rm = TRUE))

grafico_grasa_x_mes <-
  grasa_x_mes %>%
  ggplot(aes(x = mes, y = grasa_corporal)) +
  geom_col() +
  labs(title = "Grasa corporal promedio por mes") +  
  theme_minimal()

ggplotly(grafico_grasa_x_mes)

Músculo esquelético por mes

musculo_x_mes <-
  bioestadisticas %>%
  mutate(mes = format_ISO8601(fecha, precision = "ym")) %>%
  group_by(mes) %>%
  summarise(musculo_esqueletico = mean(musculo_esqueletico, na.rm = TRUE))

grafico_musculo_x_mes <-
  musculo_x_mes %>%
  ggplot(aes(x = mes, y = musculo_esqueletico)) +
  geom_col() +
  labs(title = "Músculo esquelético promedio por mes") +  
  theme_minimal()

ggplotly(grafico_musculo_x_mes)

Natación

Natación (distancia medida manualmente) vs. peso

natacion_manual_peso <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_manual, y = peso)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Natación (distancia medida manualmente) vs. peso") +  
  theme_minimal()

ggplotly(natacion_manual_peso)

Natación (distancia medida por el reloj) vs. peso

natacion_reloj_peso <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_reloj, y = peso)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  theme_minimal()

ggplotly(natacion_reloj_peso)

Natación (distancia medida manualmente) vs. grasa corporal

natacion_manual_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_manual, y = grasa_corporal)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Natación (distancia medida manualmente) vs. grasa corporal") +  
  theme_minimal()

ggplotly(natacion_manual_grasa)

Natación (distancia medida por el reloj) vs. grasa corporal

natacion_manual_reloj <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_reloj, y = grasa_corporal)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Natación (distancia medida por el reloj) vs. grasa corporal") +  
  theme_minimal()

ggplotly(natacion_manual_reloj)

Natación (distancia medida manualmente) vs. músculo esquelético

natacion_manual_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_manual, y = musculo_esqueletico)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Natación (distancia medida manualmente) vs. músculo esquelético") +  
  theme_minimal()

ggplotly(natacion_manual_musculo)

Natación (distancia medida por el reloj) vs. músculo esquelético

natacion_reloj_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = natacion_distancia_reloj, y = musculo_esqueletico)) +
  geom_point(color = "blue") +
  geom_smooth(color = "black") +
  labs(title = "Natación (distancia medida por el reloj) vs. músculo esquelético") +  
  theme_minimal()

ggplotly(natacion_reloj_musculo)

Fecha

Fecha y peso

fecha_peso <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = peso)) +
  geom_line(color = "blue") +
  geom_smooth(method = "loess", color = "black") +
  theme_minimal()

ggplotly(fecha_peso)

Fecha y grasa corporal

fecha_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = grasa_corporal)) +
  geom_line(color = "blue") +
  geom_smooth(color = "black") +
  theme_minimal()

ggplotly(fecha_grasa)

Fecha y músculo esquelético

fecha_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = musculo_esqueletico)) +
  geom_line(color = "blue") +
  geom_smooth(color = "black") +
  theme_minimal()

ggplotly(fecha_musculo)

Fecha y natación (distancia medida manualmente)

fecha_natacion_manual <-
  bioestadisticas %>%
  filter(!is.na(natacion_distancia_manual) & !is.na(natacion_distancia_reloj)) %>%
  ggplot() +
  geom_line(aes(x = fecha, y = natacion_distancia_manual), color = "blue") +
  geom_smooth(
    aes(x = fecha, y = natacion_distancia_manual),
    color = "black"
  ) +
  theme_minimal()

ggplotly(fecha_natacion_manual)

Fecha y natación (distancia medida por el reloj)

fecha_natacion_reloj <-
  bioestadisticas %>%
  filter(!is.na(natacion_distancia_manual) & !is.na(natacion_distancia_reloj)) %>%
  ggplot() +
  geom_line(aes(x = fecha, y = natacion_distancia_reloj), color = "blue") +
  geom_smooth(
    aes(x = fecha, y = natacion_distancia_reloj),
    color = "black"
  ) +
  theme_minimal()

ggplotly(fecha_natacion_reloj)